package com.mender.api.client;

import com.mender.common.result.Result;
import com.mender.domain.dto.GoodsSalesDTO;
import com.mender.domain.po.Orders;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * trade-service-->订单、购物车业务
 */
@FeignClient(name = "trade-service")
public interface TradeClient {

    /**
     * 查询总订单数
     */
    @PostMapping("/admin/order/countByMap")
    Result<Integer> countOrderByMap(@RequestBody Map<String, Object> params);

    /**
     * 查询所有已完成订单数据（一次性查出范围内所有订单）
     * getCompletedOrdersByTime
     */
    @GetMapping("/admin/order/getCompletedOrders")
    Result<List<Orders>> getCompletedOrdersByTime(
            @RequestParam("beginTime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime beginTime,
            @RequestParam("endTime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")LocalDateTime endTime,
            @RequestParam(required = false) Integer status);

    /**
     * 营业额统计
     */
    @PostMapping("/admin/order/sumByMap")
    Result<Double> sumOrderByMap(@RequestBody Map<String, Object> params);



    /**
     * 根据指定时间查询符合条件的菜品
     * @param beginTime
     * @param endTime
     * @return
     */
    @GetMapping("/admin/order/getOrderDetailTop10")
    Result<List<GoodsSalesDTO>> getOrderDetailTop10(
            @RequestParam("beginTime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime beginTime,
            @RequestParam("endTime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")LocalDateTime endTime);
}
